package nccloud.api.uapbd.file;

import java.io.IOException;
import java.util.List;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.restlet.Request;
import org.restlet.ext.servlet.ServletUtils;
import org.restlet.representation.Representation;

public class RestletFileUpload extends ServletFileUpload {
    public RestletFileUpload() {
    }

    public RestletFileUpload(FileItemFactory fileItemFactory) {
        super(fileItemFactory);
    }

    public FileItemIterator getItemIterator(Representation multipartForm) throws FileUploadException, IOException {
        return this.getItemIterator(new RepresentationContext(multipartForm));
    }

    public List<FileItem> parseRepresentation(Representation multipartForm) throws FileUploadException {
        return this.parseRequest(new RepresentationContext(multipartForm));
    }

    public List<FileItem> parseRequest(Request request) throws FileUploadException {
        return this.parseRequest(ServletUtils.getRequest(request));
    }
}
